using System;
using OWL.Rendering.HRP;
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace Yoozoo.Core.Common
{
    public class OutputScreenQualityListener : 
        QualityListenerMono,
        IOutputScreenQualityAdjuster
    {
        public bool supportsHDR = false;
        public int msaaSampleCount = 1;
        
        public void ChangeHDRMode(bool hdr)
        {
            supportsHDR = hdr;
            if (Application.platform == RuntimePlatform.IPhonePlayer) //ios不能关闭HDR，渲染会有问题
            {
                HRenderSceneManager.Inst.PipelineAsset.supportsHDR = true;
            }
            else
            {
                HRenderSceneManager.Inst.PipelineAsset.supportsHDR = hdr;
            }
            
        }

        public void ChangeMSAAMode(int msaaLevel)
        {
            //关闭硬件抗锯齿
            HRenderSceneManager.Inst.PipelineAsset.msaaSampleCount = 0;
            
            
            // // 改变Msaa时，需要拿到当前机型的建议性能分级来限制msaa等级
            // DevicesGrading.DeviceGrade grade = DevicesGrading.Instance.GetRecommondDeviceGrade();
            // int nGrade = (int) grade;
            // QualityAdjusterLimit adjusterLimit = QualityManager.Inst.GetQualityAdjusterLimit(nGrade);
            // if (adjusterLimit!=null)
            // {
            //     msaaLevel = Mathf.Min(msaaLevel, adjusterLimit.limitMSAALevel);
            // }
            //
            // msaaSampleCount = (int)Math.Pow(2, msaaLevel);
            // HRenderSceneManager.Inst.PipelineAsset.msaaSampleCount = msaaSampleCount;
        }
    }
}